<template>
	<view class="card">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				会员卡发放
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="beijing">
				<image :src="baseUrl + '/wximage/cardbj.png'" mode="widthFix" class="tp"></image>
				<view class="content">
					<view class="jilu" @click="topage('/subpackageA/business/card')">发放记录</view>
					<view class="biaoti">
						<view class="hengxian1"></view>
						<view class="title">会员卡权益</view>
						<view class="hengxian2"></view>
					</view>
					<view class="nav clearfix">
						<view class="list fl">
							<image :src="baseUrl + '/wximage/cardmy.png'"></image>
							<view class="name">免押租借</view>
						</view>
						<view class="list fl">
							<image :src="baseUrl + '/wximage/cardwy.png'"></image>
							<view class="name">超时无忧</view>
						</view>
					</view>
					<view class="fenlei clearfix">
						<view class="list fl" v-for="(item,index) in list" :key="index">
							<image :src="baseUrl + '/wximage/cardflbj.png'"></image>
							<view class="attr">{{item.title}}</view>
							<view class="bottom">
								<view class="shuzi">{{item.sycount}}</view>
								<view class="shengyu">
									<text>当月剩余</text>
									<text>月卡数量(张)</text>
								</view>
							</view>
						</view>
					</view>
					<view class="fafang">
						<view class="nr" @click="topage('/subpackageA/card/grent')">
							<image :src="baseUrl + '/wximage/cardffbj.png'"></image>
							<view class="name">定向发放</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				list: [],
			}
		},
		onLoad() {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
		},
		onShow() {
			this.request({
				url: '/xcx/membershipcardList',
				data: {},
				method: "POST"
			}).then(res => {
				if (res.data.code == 200) {
					this.list = res.data.data;
				} else {
					uni.showToast({
						title: '请求失败，请稍后再试',
						icon: 'none'
					})
				}
			})
		},
		methods: {
			topage(url){
				uni.navigateTo({
					url
				})
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		width: 100%;
		margin: 0 auto;
		height: 100vh;
		background: #f9f9ff;
		overflow-y: scroll;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				text {
					font-size: 24rpx;
				}

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 20rpx 40rpx 0;
			box-sizing: border-box;
			
			.beijing{
				width: 100%;
				position: relative;
				
				.tp{
					width: 100%;
				}
				
				.content{
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					
					.jilu{
						width: 100%;
						padding: 24rpx 24rpx 0;
						text-align: right;
						font-size: 24rpx;
						color: #E7CFA5;
					}
					
					.biaoti{
						width: 340rpx;
						margin: 0 auto;
						text-align: center;
						position: relative;
						
						.title{
							font-size: 28rpx;
							font-weight: 700;
							color: #FFFFFF;
						}
						
						.hengxian1{
							width: 80rpx;
							height: 2rpx;
							border-radius: 2rpx;
							background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
							position: absolute;
							top: 18rpx;
							left: 0;
						}
						
						.hengxian2{
							width: 80rpx;
							height: 2rpx;
							border-radius: 2rpx;
							background: linear-gradient(90deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
							position: absolute;
							top: 18rpx;
							right: 0;
						}
					}
					
					.nav{
						width: 82%;
						margin: 0 auto;
						margin-top: 60rpx;
						
						.list{
							width: 50%;
							text-align: center;
							
							image{
								width: 100rpx;
								height: 100rpx;
							}
							
							.name{
								font-size: 24rpx;
								color: #FFFFFF;
								margin-top: 20rpx;
							}
						}
					}
					
					.fenlei{
						width: 100%;
						padding: 0 20rpx;
						margin-top: 60rpx;
						
						.list{
							width: 198rpx;
							height: 240rpx;
							margin-right: 16rpx;
							position: relative;
							margin-bottom: 60rpx;
							
							image{
								width: 200rpx;
								height: 240rpx;
							}
							
							.attr{
								position: absolute;
								font-size: 24rpx;
								color: #333333;
								font-weight: 700;
								top: 0;
								right: 26rpx;
							}
							
							.bottom{
								position: absolute;
								width: 100%;
								left: 0;
								top: 70rpx;
								text-align: center;
								
								.shuzi{
									font-size: 60rpx;
									color: #E7CFA5;
									font-weight: 700;
									margin-bottom: 10rpx;
								}
								
								.shengyu{
									
									text{
										font-size: 22rpx;
										color: #E7CFA5;
										line-height: 30rpx;
										display: block;
									}
								}
							}
						}
						
						.list:nth-of-type(3n){
							margin-right: 0;
						}
					}
					
					.fafang{
						width: 100%;
						margin-top: 60rpx;
						background: #333333;
						padding: 30rpx 0;
						
						.nr{
							width: 200rpx;
							height: 64rpx;
							margin: 0 auto;
							position: relative;
							
							image{
								width: 200rpx;
								height: 64rpx;
							}
							
							.name{
								font-size: 24rpx;
								width: 100%;
								text-align: center;
								color: #202327;
								position: absolute;
								top: 0;
								left: 0;
								height: 64rpx;
								line-height: 64rpx;
							}
						}
					}
				}
			}
		}
	}
</style>